<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>编辑栏目</title>
    <meta content="webkit" name="renderer">
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"
          name="viewport">
    <link href="/static/layui/css/layui.css" media="all" rel="stylesheet">
    <link href="/static/admin/style/admin.css" media="all" rel="stylesheet">
    <style>
        .add_order .layui-form-label {
            width: 150px;
        }
        .add_order .layui-input-block {
            margin-left: 180px;
        }
        .file-box img{margin-top:15px;}
.file-box{position:relative;width:800px}
.file-txt{width:660px;height:36px;line-height:36px;background:#fff;border:0 solid #fff;padding-left:5px}
.file-box i{position:absolute;left:16px;top:11px;font-size:16px;color:#5FB878}
.file-btn:hover{border-color:#D2D2D2!important}
.file-btn{width:110px;height:36px;line-height:36px;background:#fff;border:1px solid #e6e6e6;padding-left:15px;border-radius:2px}
.file-file{position:absolute;top:0;left:0;height:36px;filter:alpha(opacity:0);opacity:0;width:110px}
    </style>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body add_order">
                    <form action="" class="layui-form" lay-filter="component-form-element">
                        <div class="layui-row layui-col-space10 layui-form-item">
                            <div class="layui-col-md12">
                                <label class="layui-form-label">栏目：</label>
                                <div class="layui-input-block">
                                    <select name="catid">
                                        {volist name="cateList" id="vo"}
                                        <option value="{$vo.id}" {if $vo.id eq $item.catid}selected{/if}>{$vo.catname}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                            <div class="layui-col-md12">
                                <label class="layui-form-label">文章标题：</label>
                                <div class="layui-input-inline" style="width: 600px;">
                                    <input autocomplete="off" class="layui-input" lay-verify="required" name="title"
                                        placeholder="" type="text" value="{$item.title}">
                                </div>
                                <div class="layui-input-inline" style="width: 120px;">
                                    <input type="text" value="{$item.color}" name="color" placeholder="请选择颜色" class="layui-input"
                                        id="test-form-input">
                                </div>
                                <div class="layui-inline" style="left: -11px;">
                                    <div id="test-form"></div>
                                </div>
                            </div>
                            <div class="layui-col-md12">
                                <label class="layui-form-label">图片</label>
                                <a class="layui-btn" id="image" style="float: left;"><i
                                        class="layui-icon">&#xe67c;</i>上传图片</a>
                                <div class="layui-input-block" style="margin-left: 295px;">
                                    <input type="text" name="pic" value="{$item.pic}" class="layui-input"
                                        style="position: absolute;left: 0;top: 0;">
                                </div>
                                <div class="layui-form-item" style="margin-top: 5px;">
                                    <img style="margin-left: 180px;" id="img" src="{$item.pic}" width="200">
                                </div>
                            </div>
                            <div class="layui-col-md12">
                                <label class="layui-form-label">关键字：</label>
                                <div class="layui-input-inline" style="width: 600px">
                                    <input autocomplete="off" class="layui-input" name="keyword"
                                        placeholder="用英文逗号隔开" type="text" value="{$item.keyword}">
                                </div>
                                <div class="layui-form-mid layui-word-aux">用英文逗号隔开</div>
                            </div>
                            <div class="layui-col-md12">
                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">简介：</label>
                                    <div class="layui-input-block">
                                        <textarea class="layui-textarea" name="description" placeholder="">{$item.description}</textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md12">
                                <label class="layui-form-label">点击数：</label>
                                <div class="layui-input-block">
                                    <input autocomplete="off" class="layui-input" name="onclick" placeholder="" type="text" style="width: 100px;" value="{$item.onclick}">
                                </div>
                            </div>
                            <div class="layui-col-md12">
                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">文章内容：</label>
                                    <div class="layui-input-block">
                                        <textarea name="content" id="content" lay-verify="required">{$item.content}</textarea>
                                        <input type="hidden" name="id" value="{$item.id}"/>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md12">
                                <label class="layui-form-label">是否发布</label>
                                <div class="layui-input-block">
                                    <input type="radio" name="status" value="1" title="是" {if $item.status eq 1}checked{/if}>
                                    <input type="radio" name="status" value="0" title="否" {if $item.status eq 0}checked{/if}>
                                </div>
                            </div>

                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-filter="component-form-element" lay-submit>立即提交
                                </button>
                                <button class="layui-btn layui-btn-primary" type="reset">重置</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="/static/common/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/admin/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/static/admin/ueditor/ueditor.all.js"></script>
<script src="/static/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/admin/' //静态资源所在路径
    }).use(['form'], function () {
        var $ = layui.$
            , admin = layui.admin
            , element = layui.element
            , form = layui.form;

            var ue = UE.getEditor('content');
            ue.ready(function() {
                ue.setHeight(400);
            });


        form.on('submit(component-form-element)', function (data) {

            $.post("{:url('article/edit')}", data.field, function (res) {

                if (0 == res.code) {

                    layer.msg(res.msg);
                    setTimeout(function () {

                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        window.parent.renderTable();
                    }, 200);
                } else {

                    layer.alert(res.msg, {
                        'title': '添加错误',
                        'icon': 2
                    });
                }
            }, 'json');
            return false;
        });
    });
</script>
</body>
</html>